import {
	getUserToken
} from "./storage.js"
export const uploadFilePromise = (data) => {
		return new Promise((resolve, reject) => {
			uni.showLoading({
				title:"上传中"
			})
			let a = uni.uploadFile({
				url: 'https://job.ydylmold.cn/base/upload/file',
				filePath: data.url,
				name: 'file',
				formData: {
					...data.params,
					fileParaName: 'file'
				},
				header:{
					token:getUserToken()
				},
				success: (res) => {					
					let data = JSON.parse(res.data);
					if (data.code === 200) {
						uni.hideLoading();
						setTimeout(() => {
							resolve(data.data);
							uni.showToast({
								title: "上传成功",
								duration: 2000
							})
							
						}, 1000)
					} else {
						uni.showToast({
							title: "上传失败",
							duration: 2000,
							icon:'none'
						})
					}

				},
				fail:(err)=>{
					uni.hideLoading()
					uni.showToast({
						title: "上传失败",
						duration: 2000,
						icon:'none'
					})
				}
			});
		})
	}
